﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HPCloud.Common.DataAccess
{
    public enum GenericCallResultEnum
    {
        Success               = 0,
        Unauthorized          = 1,
        AccessDenied          = 2,
        ValidationFaiure      = 3
    }

    public class CallResult <T, U>
    {
        //private GenericCallResultEnum _genericResult;
        private T _returnValue;
        private U _domainResult;
        
        #region Properties
//===================================================================================================
/// <summary>
/// 
/// </summary>
//===================================================================================================
        //public GenericCallResultEnum GenericResultCode
        //{
        //    get { return _genericResult; }
        //    set { _genericResult = value; }
        //}
//===================================================================================================
/// <summary>
/// 
/// </summary>
//===================================================================================================
        public U DomainResultCode
        {
            get { return _domainResult; }
            set { _domainResult = value; }
        }
//===================================================================================================
/// <summary>
/// 
/// </summary>
//===================================================================================================
        public T ReturnValue
        {
            get
            {
                return _returnValue;
            }
            set
            {
                _returnValue = value;
            }
        }
        #endregion
        #region Methods
//===================================================================================================
/// <summary>
/// 
/// </summary>
/// <param name="httpStatusCode"></param>
//===================================================================================================
        public static GenericCallResultEnum GetStatus(string httpStatusCode)
        {
            switch (httpStatusCode)
            {
                case ("200 OK"):
                    return GenericCallResultEnum.Success;

                case ("401 Unauthorized"):
                    return GenericCallResultEnum.Unauthorized;
  
                case ("403 Forbidden"):
                    return GenericCallResultEnum.Unauthorized;

                case ("415 Unsupported Media Type"):
                    return GenericCallResultEnum.ValidationFaiure;
             }

            return GenericCallResultEnum.Success;
        }
        #endregion
    }
}
